Repository navigation
Add Phone PWA, QR-code pairing, and VAPID Web Push notifications - #382
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes Bate's embedded device page feel like a companion phone app with QR-code pairing, installable PWA metadata, and encrypted Web Push notifications — with zero new dependencies:
proto/src/qr.rs,appd/src/lan.rs,window/ui/src/Devices.tsx,native/src/settings_devices.rs):proto::qr::encode, Byte mode, EC Level M, versions 1–10) producing both compact row matrices and crisp SVG paths with a 4-module quiet zone.pair_devicenow includesurl(https://<host>:<port>/?pair=<code>) andqr({size, rows}) when a network address is available.native(visually verified in light/dark snapshots) andwindow/ui.Pairinwindow/ui/src/Devices.tsxpre-fills the code from?pair=<code>and strips it from browser history.window/ui/index.html,window/ui/public/{manifest.webmanifest,icon.svg,sw.js},window/ui/src/style.css,appd/src/lan.rs):viewport-fit=cover) + safe-area inset rules, SVG icon, and minimal Service Worker (push+notificationclick), served over LAN/Tailscale HTTPS with proper MIME types andService-Worker-Allowed: /.appd/src/push.rs,appd/src/lan.rs,appd/src/core.rs,window/ui/src/service.ts):vapid.key, never in logs, frames, orapp.db), encrypting payloads with RFC 8291 (aes128gcm) and signing requests with RFC 8292 ES256 JWTs usingring./api/push/key,/api/push/subscribe, and/api/push/unsubscribeendpoints; removing a Device clears its subscriptions and expired404/410subscriptions are pruned automatically.Needs you) or finishes a Routine, strictly redacting Secret prompts so bot text and secret names never appear in push payloads.Closes #375.
Evidence
cd window/ui && npm ci && npm run build && npm test: passed (142/142 tests, includingstyle.test.tsandstandin.test.mjs).cargo fmt --all --check: passed.cargo clippy --workspace --all-targets --locked -- -D warnings: passed.cargo test --workspace --locked --no-fail-fast: passed across all crates, including:proto::qr::tests::encodes_pairing_urls_deterministically_with_valid_finders_and_svgappd::push::tests::{base64url_round_trips, secret_prompt_payload_redacts_bot_text_and_secret_names, vapid_jwt_and_rfc8291_encryption_produce_valid_frames, subscription_validation_rejects_non_https_and_bad_keys}appd/tests/service.rs::pwa_manifest_qr_pairing_and_web_push_subscription_lifecyclenative/tests/settings.rs(44/44 passed, assertingpair-qrrenders and visually verifying updatednative-settings-pairing-{light,dark}.png).Merge Danger
Low. Adds optional
url/qrfields topair_device, static PWA files, and paired-device-only/api/push/*routes. No existing socket command or schema changes; Web Push stays inactive until a paired Device subscribes.Device decision
ALLOWED_OVER_LAN/REFUSED_OVER_LANunchanged).pair_deviceremains refused from paired Devices;/api/push/{key,subscribe,unsubscribe}require a valid paired Device cookie plusx-bate: 1, and a Device can only manage its own subscriptions.